
package com.health.util;

/**
 * @author gaowen
 * @createDate 2013-7-11
 * @version 1.0
 * @tags 
 */
/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.


import java.io.Serializable;
/**
 * from CBMS
 * */
public class Page implements Serializable
{
    public static final int DEFAULT_PAGE_SIZE = 20;
    private int start;
    private int pageSize;
    private int currentPageSize;
    private int currentPageNo;
    private Object data;
    private int totalSize;
    private int totalPageCount;
    
	private static final long serialVersionUID = 6792830381811225667L;
    /**
	 * 
	 */
	public Page()
    {
        this(0, 0, 0, 20, new Object());
    }

    public Page(int start, int currentPageSize, int totalSize, int pageSize, Object data)
    {
        this.pageSize = 20;
        this.currentPageSize = currentPageSize;
        this.pageSize = pageSize;
        this.start = start;
        this.totalSize = totalSize;
        this.data = data;
        if(pageSize <= 0)
            pageSize = 1;
        currentPageNo = (start - 1) / pageSize + 1;
        totalPageCount = ((totalSize + pageSize) - 1) / pageSize;
        if(totalSize == 0 && currentPageSize == 0)
        {
            currentPageNo = 1;
            totalPageCount = 1;
        }
    }

    public int getTotalSize()
    {
        return totalSize;
    }

    public int getTotalPageCount()
    {
        return totalPageCount;
    }

    public int getPageSize()
    {
        return pageSize;
    }

    public Object getResult()
    {
        return data;
    }

    public int getCurrentPageNo()
    {
        return currentPageNo;
    }

    public int getSize()
    {
        return currentPageSize;
    }

    public boolean hasNextPage()
    {
        return getCurrentPageNo() < getTotalPageCount();
    }

    public boolean hasPreviousPage()
    {
        return getCurrentPageNo() > 1;
    }

    protected int getStartOfPreviousPage()
    {
        return Math.max(start - pageSize, 1);
    }

    protected int getStartOfNextPage()
    {
        return start + currentPageSize;
    }

    protected static int getStartOfPage(int pageNo)
    {
        return getStartOfPage(pageNo, 20);
    }

    protected static int getStartOfPage(int pageNo, int pageSize)
    {
        int startIndex = (pageNo - 1) * pageSize;
        if(startIndex < 0)
            startIndex = 0;
        return startIndex;
    }

    public int getCurrentPageSize()
    {
        return currentPageSize;
    }

    public void setCurrentPageSize(int currentPageSize)
    {
        this.currentPageSize = currentPageSize;
    }

    public Object getData()
    {
        return data;
    }

    public void setData(Object data)
    {
        this.data = data;
    }

    public int getStart()
    {
        return start;
    }

    public void setStart(int start)
    {
        this.start = start;
    }

    public void setCurrentPageNo(int currentPageNo)
    {
        this.currentPageNo = currentPageNo;
    }

    public void setPageSize(int pageSize)
    {
        this.pageSize = pageSize;
    }

    public void setTotalPageCount(int totalPageCount)
    {
        this.totalPageCount = totalPageCount;
    }

    public void setTotalSize(int totalSize)
    {
        this.totalSize = totalSize;
    }


}


/*
	DECOMPILATION REPORT

	Decompiled from: D:\cc_view\gaowen_int_view\CBMS\3编码实现\cbms\WebContent\WEB-INF\lib\cn.gov.pbc.fsp.common.jar
	Total time: 156 ms
	Jad reported messages/errors:
	Exit status: 0
	Caught exceptions:
*/